home *** CD-ROM | disk | FTP | other *** search
-
- var scrollToBottomIsNeeded = false;
- var newMsgCounter = 0;
- var newMsgButtonVisible = true;
-
- function scrollToBottom() {
- smoothScrollToBottom();
- if (newMsgButtonVisible) {
- pulsateNewMsgButton(true);
- newMsgButtonVisible = false;
- slideObjectBottom("newMsgButton", 0, -32, 20, 5);
- }
- newMsgCounter = 0;
- }
-
- function checkIfScrollToBottomIsNeeded() {
- scrollToBottomIsNeeded = (document.body.scrollTop >= (document.body.offsetHeight - (window.innerHeight * 1.2)));
- alert("checkIfScrollToBottomIsNeeded() called with result " + scrollToBottomIsNeeded);
- }
-
- function scrollToBottomIfNeeded() {
- if ( scrollToBottomIsNeeded || scrolling )
- scrollToBottom();
- else {
- newMsgCounter++;
- document.getElementById("newMsgCounter").innerHTML =
- newMsgCounter +
- " new message" +
- (newMsgCounter > 1 ? "s" : "");
- if (!newMsgButtonVisible && newMsgCounter != 0) {
- newMsgButtonVisible = true;
- slideObjectBottom("newMsgButton", -32, 0, 20, 1);
- pulsateNewMsgButton(true);
- }
- }
- }
-
- var scrollID;
- var scrolling = false;
- function smoothScrollToBottom() {
- if (scrolling)
- window.clearInterval(scrollID);
- scrolling = true;
- var y0 = window.scrollY;
- var y1 = document.body.offsetHeight;
- var steps = 15;
- var delay = 1;
- var incr = (y1 - y0) / steps;
- var y = y0;
- scrollID = window.setInterval(function () {
- y += incr;
- if ((y0 < y1 && y1 < y) || (y0 > y1 && y1 > y)) {
- scrolling = false;
- window.clearInterval(scrollID);
- }
- else
- window.scrollTo(0, y);
- }, delay);
- }
-
-
- var pulsateID;
- var currentPulsateNum = 1;
- var pulsateIncr = 1;
- function pulsateNewMsgButton(activate) {
- var obj = document.getElementById("newMsgCounter");
- obj.style.backgroundImage = 'url("images/NewMsgButton/NewMessage_1.png")';
- window.clearInterval(pulsateID);
-
- if (activate) {
- currentPulsateNum = 1;
- pulsateID = window.setInterval(function () {
- currentPulsateNum += pulsateIncr;
- obj.style.backgroundImage = 'url("images/NewMsgButton/NewMessage_' + currentPulsateNum + '.png")';
- if (currentPulsateNum >= 7)
- pulsateIncr = -1;
- else if (currentPulsateNum <= 1)
- pulsateIncr = 1;
- }, 100);
- }
- }
-
-
- var slideID;
- function slideObjectBottom(id, start, end, steps, delay) {
- if (slideID)
- window.clearInterval(slideID);
- var obj = document.getElementById(id);
- var incr = (end - start) / steps;
- var bottom = start;
- obj.style.bottom = bottom;
- if (start != end)
- slideID = window.setInterval(function () {
- bottom += incr;
- if ((start < end && end <= bottom) || (start > end && end >= bottom)) {
- window.clearInterval(slideID);
- }
- else
- obj.style.bottom = bottom;
- }, delay)
- }
-